package com.agg.core.base.dto;

import cn.hutool.core.date.DateUtil;
import com.agg.domain.command.BaseCmd;
import com.baomidou.mybatisplus.annotation.TableLogic;

import java.util.Date;

public class EntityDTO<E> extends BaseCmd {

    private E entity;

    private Object createId;

    private Object updateId;

    private Date createTime;

    private Date updateTime;


    @TableLogic
    //逻辑删除状态，1：有效，2：删除
    private Integer enabled;

    public EntityDTO allEx() {
        Date times = DateUtil.date();

        setUpdateTime(times);
        setCreateTime(times);
        this.createId = Long.valueOf(0L);
        this.updateId = Long.valueOf(0L);

        this.enabled = 1;
        return this;
    }

    public EntityDTO allEx(Object userId) {
        Date times = DateUtil.date();
        setCreateTime(times);
        setCreateId(userId);
        this.enabled = 1;
        return this;
    }

    public EntityDTO allTime() {
        Date times = DateUtil.date();
        setUpdateTime(times);
        setCreateTime(times);
        return this;
    }

    public EntityDTO created(Object userId) {
        setCreateTime(DateUtil.date());
        setCreateId(userId);
        this.enabled = 1;
        return this;
    }

    public EntityDTO updated(Object userId) {
        setUpdateTime(DateUtil.date());
        setUpdateId(userId);
        return this;
    }

    public EntityDTO disable(Object userId) {
        setUpdateTime(DateUtil.date());
        setUpdateId(userId);
        this.enabled = 2;
        return this;
    }



    public E getEntity() {
        return entity;
    }

    public void setEntity(E entity) {
        this.entity = entity;
    }

    public Object getCreateId() {
        return createId;
    }

    public void setCreateId(Object createId) {
        this.createId = createId;
    }

    public Object getUpdateId() {
        return updateId;
    }

    public void setUpdateId(Object updateId) {
        this.updateId = updateId;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }



    public Integer getEnabled() {
        return enabled;
    }

    public void setEnabled(Integer enabled) {
        this.enabled = enabled;
    }
}
